package com.xiyu.service.controller.admin.bed;
import com.xiyu.service.vo.bed.buildingInfo.BuildingInfoListQueryOutput;
import com.xiyu.service.vo.bed.buildingInfo.BuildingInfoUpdateInput;
import com.xiyu.service.vo.bed.buildingInfo.BuildingInfoQueryOutput;
import com.xiyu.service.vo.bed.buildingInfo.BuildingInfoQueryInput;
import com.xiyu.service.vo.bed.buildingInfo.BuildingInfoGetOutput;
import com.xiyu.service.vo.bed.buildingInfo.BuildingInfoCreateInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.bed.BuildingInfoService;

@Tag(name = "楼栋信息")
@RestController
@RequestMapping("/bed/building-info")
@Validated
public class BuildingInfoController {

    @Resource
    private BuildingInfoService buildingInfoService;

    @PostMapping("/create")
    @Operation(summary = "创建楼栋")
    @PreAuthorize("@ss.hasPermission('bed:building:create')")
    public CommonResult<Long> create(@Valid @RequestBody BuildingInfoCreateInput inputVO) {
        return success(buildingInfoService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新楼栋")
    @PreAuthorize("@ss.hasPermission('bed:building:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody BuildingInfoUpdateInput inputVO) {
        return success(buildingInfoService.update(inputVO));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除楼栋")
    @PreAuthorize("@ss.hasPermission('bed:building:deleted')")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(buildingInfoService.deleted(id));
    }

    @GetMapping("/get")
    @Operation(summary = "获取单个楼栋")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<BuildingInfoGetOutput> get(@RequestParam("id") Long id) {
        return success(buildingInfoService.get(id));
    }

    @GetMapping("/query")
    @Operation(summary = "分页查询楼栋")
    @PreAuthorize("@ss.hasPermission('bed:building:query')")
    public CommonResult<PageResult<BuildingInfoQueryOutput>> query(@Valid BuildingInfoQueryInput inputVO) {
        return success(buildingInfoService.query(inputVO));
    }

    @GetMapping("/list-query")
    @Operation(summary = "查询楼栋信息")
    public CommonResult<List<BuildingInfoListQueryOutput>> listQuery() {
        return success(buildingInfoService.listQuery());
    }

}
